package com.gxa.insurance.controller;

import com.gxa.insurance.pojo.Role;
import com.gxa.insurance.service.RoleService;
import com.gxa.insurance.util.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author wang li sha
 * @date 2022-06-06 17:58
 */
@Api(value = "角色role相关的api接口")
@RestController
@RequestMapping("/role")
@CrossOrigin
public class RoleController {
    @Autowired
    RoleService roleService;

    @ApiOperation("查询所有角色的方法")
    @PostMapping("/selectAll")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "用户token", paramType = "header")
    })
    public Map selectAll(@RequestHeader(value = "token", required = false) String token) throws Exception {
        List<Role> roles = roleService.selectAll();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(roles);
        return jsonResult.getMap();
    }

}
